home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_43452.txt < prev    next >
Text File  |  1991-02-27  |  2KB  |  32 lines

  1. -- card: 43452 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. accessible only within member functions of the class, within member functions of derived classes as well, and via the object identifier (using '.' or '->' operators) as well, respectively.  Thus a class defined with the 'struct' keyword is equivalent to one defined with the 'class' keyword using only 'public' specifiers.
  11.  
  12. Enforcing strict scope rules helps to clarify the interface among classes.  For example, in many cases the instance variables of a class should be inaccessible ("hidden") to other classes, while a few public member functions should remain to provide well-defined communication.  C++ also provides the ability to declare some classes as 'friends' with members of another class, to circumvent the usual privacy.
  13.  
  14. (A limitation of these custom scopes is that objects of a given class can always access private parts of other objects of the same class.  Bjarne Stroustrup says, "The unit of protection in C++ is a class, not an individual object of a class", on p. 138 of his book*.)
  15.  
  16. While TC does not provide such scope restrictions as part of the language, it is good programming practice to use comments to explicitly state which members of the class may be considered "public" and which should be accessed only by member functions.
  17.  
  18. -- part contents for background part 7
  19. ----- text -----
  20. 113
  21.  
  22. -- part contents for background part 29
  23. ----- text -----
  24. 2231
  25.  
  26. -- part contents for background part 27
  27. ----- text -----
  28. Bibliography
  29.  
  30. -- part contents for background part 20
  31. ----- text -----
  32. Bibliography - p221